package chapter03

object Test01_TestOperator {
  def main(args: Array[String]): Unit = {
    //算术运算符
    val result1 = 10 / 3
    println(result1)
    val result2: Double = 10 / 3
    println(result2)
    val result3: Double = 10.0 / 3
    println(result3.formatted("%.2f"))
    //2.比较运算符
    val s1: String = "hello"
    val s2: String = new String("hello")
    println(s1 == s2)
    println(s1.eq(s2))
    //3. 逻辑运算符
    val n = 1

    def m(n: Int): Int = {
      println("m被调用")
      n
    }
    //短路操作
    println((4 > 5) && m(n) > 0)

    def isNotEmpty(str: String): Boolean = {
      return str != null && !("".equals(str))
    }

    println(isNotEmpty(null))
    //赋值运算符
    var b: Byte = 10
    b = (b + 1).toByte
    println(b)

    // 运算符的本质
    val n1: Int = 15
    val n2: Int = 16
    println(n1.+(n2))

  }
}
